﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Royaumes_Libres.Database;

namespace Royaumes_Libres
{
    public partial class ucKingdomMap : System.Web.UI.UserControl
    {
        public cMapKingdom mapKingdom;
        public cUsers pUser;
        public cKingdom Kingdom;
        public bool isMine;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Properties.Settings.Default.ObjUser] != null)
            {
                pUser = (cUsers)Session[Properties.Settings.Default.ObjUser];
                Kingdom = new cKingdom(pUser.PkUser, pUser.ActiveWorld);
            }
            if (isMine)
            {
                this.infoKingdomMap.Visible = false;
            }
            FillCell();
        }

        protected void FillCell()
        {
            this.divKingdomMap.Style.Add("background-image", "url(./images/races/" + mapKingdom.pRace + ".png)");
            this.divKingdomMap.Style.Add("background-position", "center");
            this.divKingdomMap.Style.Add("background-repeat", "no-repeat");
            this.lblKingdomName.Text = mapKingdom.pName;
            this.lblTimeTravel.Text = cAttack.GetTimeTravel(Kingdom.PkKingdom, mapKingdom.pPkKingdom).ToString() +" "+ cText.GetText("Hour");
            this.btnAttack.Text = cText.GetText("Attack");
        }

        protected void btnAttack_Click(object sender, EventArgs e)
        {
            Cache["PkKingdomDef"] = mapKingdom.pPkKingdom;
            Response.Redirect("usercombat.aspx");
        }
    }
}